﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body class="no-skin">
    <!-- 以下为内容 -->
    <div class="main-content1">
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try {
                    ace.settings.check('breadcrumbs', 'fixed')
                } catch (e) {
                }
            </script>
            <ul class="breadcrumb" style="margin-top:10px">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="#">后台管理 </a></li>
                <li class="active">岗位维护</li>
            </ul>
            <!-- 路径结束 -->
        </div>

        <div class="page-content">
            <div class="row">
                <div class="tab-content no-border padding-0">
                    <div class="col-sm-3">
                        <div class="widget-box ">
                            <div class="widget-header">
                                <h4 class="widget-title lighter smaller">所属组织机构</h4>
                            </div>
                            <div class="widget-body" style="height:400px; overflow-y:auto">
                                <div class="widget-main padding-8">
                                    <ul id="treeDemo" class="ztree"></ul>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-9">
                        <iframe src="" id="rightList" name="rightList" frameborder="0"
                                style="width:100%; height:800px"></iframe>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        //节点点击事件
        function zTreeOnClick(event, treeId, treeNode) {
            $("#rightList").attr("src", contextPath + "/auth/position/toPosList.htm?orgCode=" + treeNode.orgCode);
        }

        function zTreeBeforeClick(treeId, treeNode, clickFlag) {
            return (null != treeNode.parentCode);
        }


        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    idKey: "orgCode",
                    pIdKey: "parentCode",
                    rootPId: null
                },
                key: {
                    name: "orgName"
                }
            },
            callback: {
                beforeClick: zTreeBeforeClick,
                onClick: zTreeOnClick
            }
        };

        //得到树
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: 'application/json',
                dataType: "json",
                url: contextPath + "/auth/org/getOrganTreeData.json",
                success: function (data) {
                    $.fn.zTree.init($("#treeDemo"), setting, data);
                    //默认选中第一个节点
                    getSelectFirst();
                },
                error: function () {
                    $.Alert("系统错误！");
                }
            });
        });

        function getSelectFirst() {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getNodesByParam("parentCode", "0");
            if (nodes.length > 0) {
                treeObj.selectNode(nodes[0], false);
                zTreeOnClick(null, "treeDemo", nodes[0]);
            }
        }

    </script>

</body>
</html>
